home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Tools & Goodies / More View Resources / Radio Groups / RadioGrp.cpp < prev    next >
Encoding:
Text File  |  1996-04-19  |  4.1 KB  |  150 lines  |  [TEXT/CWIE]

  1. //========================================================================================
  2. //
  3. //    File:                RadioGrp.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Author:                Laurent Delamare
  7. //
  8. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #include "Form.hpp"
  13.  
  14. #ifndef RADIOGRP_H
  15. #include "RadioGrp.h"
  16. #endif
  17.  
  18. // ----- Framework Layer -----
  19.  
  20. #ifndef FWUTIL_H
  21. #include "FWUtil.h"
  22. #endif
  23.  
  24. #ifndef FWSVIEW_H
  25. #include "FWSView.h"
  26. #endif
  27.  
  28. #ifndef FWBUTTON_H
  29. #include "FWButton.h"
  30. #endif
  31.  
  32. #ifndef FWCLUSTR_H
  33. #include "FWClustr.h"
  34. #endif
  35.  
  36. // ----- OpenDoc Includes -----
  37.  
  38. #ifndef SOM_Module_OpenDoc_Commands_defined
  39. #include <CmdDefs.xh>
  40. #endif
  41.  
  42. #ifndef SOM_Module_OpenDoc_StdProps_defined
  43. #include <StdProps.xh>
  44. #endif
  45.  
  46. #ifndef SOM_ODSession_xh
  47. #include <ODSessn.xh>
  48. #endif
  49.  
  50. #ifndef SOM_ODDispatcher_xh
  51. #include <Disptch.xh>
  52. #endif
  53.  
  54. //========================================================================================
  55. // RunTime Info
  56. //========================================================================================
  57.  
  58. #ifdef FW_BUILD_MAC
  59. #pragma segment fwgadgts
  60. #endif
  61.  
  62. FW_DEFINE_CLASS_M1(CRadioGroup, FW_CSuperView)
  63.  
  64. const FW_ClassTypeConstant LRadioGroup = FW_TYPE_CONSTANT('r','g','r','p');
  65. FW_REGISTER_ARCHIVABLE_CLASS(LRadioGroup, CRadioGroup, CRadioGroup::Create, FW_CView::Read, CRadioGroup::Destroy, FW_CView::Write)
  66.  
  67. //========================================================================================
  68. // CRadioGroup
  69. //========================================================================================
  70.  
  71. //----------------------------------------------------------------------------------------
  72. // CRadioGroup::CRadioGroup
  73. //----------------------------------------------------------------------------------------
  74.  
  75. CRadioGroup::CRadioGroup(Environment* ev, 
  76.                         FW_CSuperView* container,
  77.                         const FW_CRect& contentRect,
  78.                         ODID viewId,
  79.                         const FW_CPoint& extent) :
  80.     FW_CSuperView(ev, container, contentRect, viewId, extent, FW_kNoScrolling),
  81.     fRadioCluster(NULL)
  82. {    
  83. }
  84.  
  85. CRadioGroup::CRadioGroup(Environment* ev) :
  86.     FW_CSuperView(ev),
  87.     fRadioCluster(NULL)
  88. {    
  89. }
  90.  
  91. //----------------------------------------------------------------------------------------
  92. // CRadioGroup::~CRadioGroup
  93. //----------------------------------------------------------------------------------------
  94.  
  95. CRadioGroup::~CRadioGroup()
  96. {
  97.     // fRadioCluster is deleted when its last radio button is deleted
  98. }
  99.  
  100. //----------------------------------------------------------------------------------------
  101. //    CRadioGroup::Create
  102. //----------------------------------------------------------------------------------------
  103.  
  104. void* CRadioGroup::Create(FW_CReadableStream& stream, FW_ClassTypeConstant type)
  105. {
  106. FW_UNUSED(stream);
  107. FW_UNUSED(type);
  108.     FW_SOMEnvironment ev;
  109.     return new CRadioGroup(ev);
  110. }
  111.  
  112. //----------------------------------------------------------------------------------------
  113. //    CRadioGroup::Destroy
  114. //----------------------------------------------------------------------------------------
  115.  
  116. void CRadioGroup::Destroy(void* object, FW_ClassTypeConstant type)
  117. {
  118. FW_UNUSED(type);
  119.     CRadioGroup* self = (CRadioGroup*) object;
  120.     delete self;
  121. }
  122.  
  123. //----------------------------------------------------------------------------------------
  124. //    CRadioGroup::Flatten
  125. //----------------------------------------------------------------------------------------
  126.  
  127. void CRadioGroup::Flatten(Environment* ev, FW_CWritableStream& archive) const
  128. {
  129.     FW_CSuperView::Flatten(ev, archive);
  130.     
  131.     // To complete: this method should stream out the radio cluster
  132.     FW_DEBUG_MESSAGE("CRadioGroup::Flatten is not completed yet");
  133. }
  134.  
  135. //----------------------------------------------------------------------------------------
  136. //    CRadioGroup::InitializeFromStream
  137. //----------------------------------------------------------------------------------------
  138.  
  139. void CRadioGroup::InitializeFromStream(Environment* ev, FW_CReadableStream& stream)
  140. {
  141.     // Read-in the base resource first
  142.     FW_CSuperView::InitializeFromStream(ev, stream);
  143.     
  144.     // Read the radio cluster
  145.     FW_READ_DYNAMIC_OBJECT(stream, &fRadioCluster, FW_CRadioCluster);
  146. }
  147.  
  148.  
  149.  
  150.